<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>parse_scoreboard_data (GamedayParser)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/gameday_parser.rb, line 79</span>
        <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_scoreboard_data</span>(<span class="ruby-identifier">doc</span>, <span class="ruby-identifier">game</span>)
                <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">each_element</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">scoreboard_element</span><span class="ruby-operator">|</span>
                        <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">scoreboard_element</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'post_game'</span>
                                <span class="ruby-identifier">scoreboard_element</span>.<span class="ruby-identifier">each_element</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">post_game_element</span><span class="ruby-operator">|</span>
                                        <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">post_game_element</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'winning_pitcher'</span>
                                                <span class="ruby-identifier">gd_id</span> = <span class="ruby-identifier">post_game_element</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">'id'</span>]
                                                <span class="ruby-identifier">player</span> = <span class="ruby-constant">Player</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:first</span>, <span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span><span class="ruby-node">&quot;gameday_id=#{gd_id}&quot;</span>)
                                                <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">player</span>) 
                                                        <span class="ruby-identifier">game</span>.<span class="ruby-identifier">update_attribute</span>(<span class="ruby-identifier">:winning_pitcher_id</span>, <span class="ruby-identifier">player</span>.<span class="ruby-identifier">id</span>)
                                                <span class="ruby-keyword kw">end</span>
                                        <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">post_game_element</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'losing_pitcher'</span>
                                                <span class="ruby-identifier">gd_id</span> = <span class="ruby-identifier">post_game_element</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">'id'</span>]
                                                <span class="ruby-identifier">player</span> = <span class="ruby-constant">Player</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:first</span>, <span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span><span class="ruby-node">&quot;gameday_id=#{gd_id}&quot;</span>)
                                                <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">player</span>) 
                                                        <span class="ruby-identifier">game</span>.<span class="ruby-identifier">update_attribute</span>(<span class="ruby-identifier">:losing_pitcher_id</span>, <span class="ruby-identifier">player</span>.<span class="ruby-identifier">id</span>)
                                                <span class="ruby-keyword kw">end</span>
                                        <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">post_game_element</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'save_pitcher'</span>
                                                <span class="ruby-identifier">gd_id</span> = <span class="ruby-identifier">post_game_element</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">'id'</span>]
                                                <span class="ruby-identifier">player</span> = <span class="ruby-constant">Player</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:first</span>, <span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span><span class="ruby-node">&quot;gameday_id=#{gd_id}&quot;</span>)
                                                <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">player</span>) 
                                                        <span class="ruby-identifier">game</span>.<span class="ruby-identifier">update_attribute</span>(<span class="ruby-identifier">:save_pitcher_id</span>, <span class="ruby-identifier">player</span>.<span class="ruby-identifier">id</span>)
                                                <span class="ruby-keyword kw">end</span>
                                        <span class="ruby-keyword kw">end</span>
                                <span class="ruby-keyword kw">end</span>
                        <span class="ruby-keyword kw">end</span>
                <span class="ruby-keyword kw">end</span>
        <span class="ruby-keyword kw">end</span></pre>
</body>
</html>